package com.hngy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hngy.dao.EmployeeDao;
import com.hngy.domain.Employee;
import com.hngy.service.EmployeeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.DigestUtils;

import java.util.List;

/**
 * @author LiKe
 * @date 2021/12/23 15:07
 */
@Service
@Transactional

public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, Employee> implements EmployeeService {
    /**
     * 后台登录校验
     * @param employee
     * @return
     */
    @Override
    public Employee login(Employee employee) {
        //1、获取用户名
        String username = employee.getUsername();

        //2、查询用户名是否存在
        //创建添加构造器
        LambdaQueryWrapper<Employee> queryWrapper = new LambdaQueryWrapper<>();

        queryWrapper.eq(Employee::getUsername,username);

        Employee one = getOne(queryWrapper);

        return one;
    }

    @Override
    public List<Employee> myPage(int page, int pageSize,String name) {
        List<Employee> employeeList = baseMapper.myPage(page, pageSize,name);
        int countNum = baseMapper.countNum();
        return employeeList;
    }


}
